hysop.core.graph.computational_graph module¶
- class hysop.core.graph.computational_graph.ComputationalGraph(candidate_input_tensors=None, candidate_output_tensors=None, **kwds)[source]¶
Bases:
ComputationalGraphNode
Interface of an abstract graph of continuous operators (ie. a computational graph).
- Parameters:
kwds (arguments for base classes.)
Notes
- The following base class variables cannot be specified during graph construction:
variables, input_variables, output_variables
- Order of operation is: add_node, initialize, discretize,
get_work_properties, setup, apply, finalize.
Nodes can also be added during pre initialization step. Graph building is done at the end of the initialization step, after all internal nodes have been initialized.
- apply(**kwds)[source]¶
Abstract method that should be implemented. Applies this node (operator, computational graph operator…).
- available_methods()[source]¶
Returns the available methods of this node. This should return a dictionary of method as keys and possible values as a scalar or an iterable. See hysop.types.InstanceOf to support specific class types. This is used to check user method input.
- build(outputs_are_inputs=True, method=None, allow_subbuffers=False)[source]¶
Shortcut for initialize(), discretize(), get_work_properties(), setup() for quick graph initialization.
- check()[source]¶
Check if node was correctly initialized. By default this checks variables, topologies and support.
- default_method()[source]¶
Returns the default method of this node. Default methods should be compatible with available_methods. If the user provided method dictionnaty misses some method keys, a default value for this key will be extracted from the default one.
- discretize()[source]¶
Discretize this operator. By default this just sets the self.discretized flag to True. Once this flag is set one may call ComputationalGraphNode.get_work_properties() and ComputationalGraphNode.setup().
- finalize(**kwds)[source]¶
Cleanup this node (free memory from external solvers, …) By default, this does nothing
- get_domains()[source]¶
Returns all the domains used in this operator. Domains are keys and values are operators that have variables defined on this domain. If this node has no domain (ie. no input or output variables), if fills the ‘None’ domain.
- get_field_requirements()[source]¶
Called just after handle_method(), ie self.method has been set. Topology requirements are:
min and max ghosts for each input and output variables
allowed splitting directions for cartesian topologies
3) required local and global transposition state, if any. and more
They are stored in self.input_field_requirements and self.output_field_requirements.
Keys are continuous fields and values are of type hysop.fields.field_requirement.DiscreteFieldRequirements
- get_topologies()[source]¶
Returns all the topologies used in this operator. Topologies are organized by backend in a dictionnary.
- get_work_properties()[source]¶
Returns extra memory requirements of this node. This allows operators to request for temporary buffers that will be shared between operators in a graph to reduce the memory footprint and the number of allocations. By default this returns None, meanning that this node requires no extra buffers.
- handle_topologies(input_topology_states, output_topology_states)[source]¶
Called after all topologies have been set up.
Topologies are available as values of self.input_fields and self.output_fields and are mapped by continuous Field.
In addition input_topology_states are passed as argument contains input discrete topology states and output topology states that the graph builder determined. All input states and output topology states have to comply with the operator field requirements obtained with self.get_field_requirements().
- initialize(is_root=True, topgraph_method=None, outputs_are_inputs=False, search_intertasks_ops=False, **kwds)[source]¶
Initialize this node.
- Initialization step sets the following variables:
*self.method, *self.input_field_requirements *self.output_field_requirements *self.initialized
It returns self.method.
- Order of execution is:
self.pre_initialize() self._setup_method() self.handle_method() self.get_field_requirements() self._initialized = True self.post_initialize()
See ComputationalGraphNode.handle_method() to see how user method is handled. See ComputationalGraphNode.get_field_requirements() to see how topology requirements are handled.
After this method has been handled by all operators, initialization collects min and max ghosts required by each operators which will be usefull in the discretiezation step to automatically build topologies or check against user supplied topologies.
This function also sets the self.initialized flag to True (just before post initialization). Once this flag is set one may call ComputationalGraphNode.discretize().
- setup(work=None, allow_subbuffers=False)[source]¶
Setup temporary buffer that have been requested in get_work_properties(). This function may be used to execute post allocation routines. This sets self.ready flag to True. Once this flag is set one may call ComputationalGraphNode.apply() and ComputationalGraphNode.finalize().
- classmethod supports_mpi()[source]¶
Return True if this operator was implemented to support multiple mpi processes.
- classmethod supports_multiple_field_topologies()[source]¶
Should return True if an input field that is also an output field can have an input topology different from its output topology. This is usefull in Redistribute like operators. If this returns True this implies supports_multiple_topologies(). It also implies that self.variables[field] may return a set of topologies. In this case one can recover input and output topologies by using self.input_fields[field] and self.output_fields[field]. In addition one can find such fields by using the list self.multi_topo_fields which is set after ComputationalGraphNode.initialize() has been called.
- classmethod supports_multiple_topologies()[source]¶
Should return True if this node supports multiple topologies.
- to_html(path, io_rank=0, show_buttons=False)[source]¶
Generate an interactive computational graph in an html file.